<template>
  <div class="app">
    <div class="login">
      <div class="head">
        <h2>梦学谷会员管理系统</h2>
      </div>
      <el-form
        ref="ruleForm"
        :model="ruleForm"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="账号" prop="username">
          <el-input v-model="ruleForm.username"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="ruleForm.password" type="password"></el-input>
          <img src="" alt="" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')"
            >登陆</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          { required: true, message: "请输入账号", trigger: "blur" },
          { min: 1, max: 5, message: "长度在 1 到 5 个字符", trigger: "blur" },
        ],
        password: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 1, max: 5, message: "长度在 1 到 5 个字符", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.ruleForm.validate((vali) => {
        if (vali) {
          this.axios.get("/long", this.ruleForm);
          this.$router.push("/Home");
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.app {
  width: 100%;
  height: 100%;
  background: url(../assets/background.png);
}
.login {
  position: absolute;
  border-radius: 20px;
  top: 50%;
  left: 50%;
  padding: 30px 20px;
  width: 400px;
  height: 280px;
  transform: translate(-50%, -50%);
  background-color: #d4d5dd;
  .head {
    width: 350px;
    height: 32px;
    text-align: center;
  }
  .el-form {
    margin-top: 20px;
  }
}
</style>
